﻿using Microsoft.Extensions.DependencyInjection;
using System;

namespace Loong.Threading.Locks.Database
{
    public static class DatabaseLockExtensions
    {
        public static IServiceCollection AddDatabaseLock(this IServiceCollection services, Action<ResourceLockDbAccessorProvider> action)
        {
            services.AddSingleton<ILockFactory, DatabaseLockFactory>();

            var provider = new ResourceLockDbAccessorProvider(services);
            action(provider);

            return services;
        }
    }
}
